//
//  MBProgressHUD+WG.m
//  BusinessWeigong
//
//  Created by dfhb@rdd on 15/9/29.
//  Copyright © 2015年 GW. All rights reserved.
//

#import "MBProgressHUD+QB.h"

@implementation MBProgressHUD (QB)

+ (MBProgressHUD *)message:(NSString *)message
{
    return [self message:message toView:nil];
}
+ (MBProgressHUD *)message:(NSString *)message toView:(UIView *)view
{
    if (view == nil) view = [[UIApplication sharedApplication].windows lastObject];
    
    NSString *text = [NSString stringWithFormat:@"%@",message];
    // 快速显示一个提示信息
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    hud.labelText = text;
    // 隐藏时候从父控件中移除
    hud.removeFromSuperViewOnHide = YES;
    // YES代表需要蒙版效果
    hud.dimBackground = NO;
    hud.mode = MBProgressHUDModeText;
    // 边缘
    hud.margin = 15.f;
    
    // 设置距离中心点的Y方向上的偏移量
//    hud.yOffset = IS_IPHONE_5?200.f:150.f;
    hud.userInteractionEnabled = NO;
    [hud hide:YES afterDelay:0.8];

    return hud;
}
+ (void)showHub_Post
{
    [self hideHub];
    UIView *view = [UIApplication sharedApplication].keyWindow;
    [MBProgressHUD hideAllHUDsForView:view animated:YES];
    MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:view animated:YES];
    hub.userInteractionEnabled = YES;
}
+ (void)showHub_Get
{
    [self hideHub];
    UIView *view = [UIApplication sharedApplication].keyWindow;
    [MBProgressHUD hideAllHUDsForView:view animated:YES];
    MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:view animated:YES];
    hub.userInteractionEnabled = NO;
}
+ (void)hideHub
{
    UIView *view = [UIApplication sharedApplication].keyWindow;
    [MBProgressHUD hideAllHUDsForView:view animated:YES];
}
@end
